package main

import (
	"encoding/json"
	"fmt"
)

type Resp struct {
	//坑点：字段名必须大写，否则解析不出来
	Code int
	Msg  string
	Data map[string]string
}

func main() {

	jsonStr := `{
		"code": 200,
		"msg": "success",
		"data": {
		  "title": "big news",
		  "date": "2022-02-09 11:19:41"
		}
	  }`
	re := Resp{}
	err := json.Unmarshal([]byte(jsonStr), &re)
	if err != nil {
		fmt.Println("出错了", err)
	}
	fmt.Println(re)
	fmt.Println(re.Data["title"])
}
